package com.repair.admin.user.controller;

import com.repair.admin.user.service.AdminUserService;
import com.repair.api.user.request.param.UserQueryParam;
import com.repair.api.user.response.data.UserInfo;
import com.repair.api.user.service.UserFacadeService;
import com.repair.base.result.JsonResult;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author chunyu
 * @since 2024/9/27,21:09
 */
@RestController
@RequestMapping("/admin")
public class AdminUserController {

    @DubboReference
    private UserFacadeService userFacadeService;

    @Autowired
    private AdminUserService adminUserService;


    /*获取全部用户信息（分页）*/
    @GetMapping("/getAllUserInfo")
    public JsonResult<List<UserInfo>> getAllUsers(UserQueryParam userQueryParam) {
        List<UserInfo> userInfoList = adminUserService.getAllUsers(userQueryParam);
        return JsonResult.ok(userInfoList);
    }

    /*查询用户详细信息（前台）*/
    @GetMapping("selectUserInfoById")
    public JsonResult<UserInfo> selectUsersById(Long id) {
        UserInfo userInfo = adminUserService.selectUsers(id);
        return JsonResult.ok(userInfo);
    }

    /*用户等级信息*/

    /*拉黑用户BlockUser*/
    @PostMapping("/update/state/{id}")
    public JsonResult<Boolean> updateState(@PathVariable("id") Long id) {
        adminUserService.updateState(id);
        return JsonResult.ok(true);
    }

    /*通过id查询拉黑用户BlockUser*/
    @GetMapping("selectBlockUserInfoById")
    public JsonResult<UserInfo> selectBlockUserById(Long id) {
       UserInfo userInfo= adminUserService.selectBlockUser(id);
        return JsonResult.ok(userInfo);
    }
    /*查询全部拉黑用户*/


}
